<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /*
            Animal
                - sleep
            Person

            ES6 面向对象

            1. class
            2. constructor
            3. super
        */
        
        class Animal {
            constructor(age) {
                // 构造函数
                this.age = age
            }
            sleep() {
                console.log(`${this.name} 正在睡觉 age: ${this.age}`)
            }
        }

        class Person extends Animal {
            constructor(name, age) {
                super(age);
                this.name = name;
            }
            eat() {
                console.log(`${this.name} 正在吃饭`);
            }
        }

        let p = new Person('石兴龙', 18)

        p.sleep()
        p.eat()

    </script>
</body>
</html>